import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
games = pd.read_csv("vgsales.csv")
games.shape
games.count()
games.info()
games
platforms = games["Platform"].unique()
platforms
genres = games["Genre"].unique()
genres
publishers = games["Publisher"].unique()
publishers.shape
games.describe()
platform_count = []
for p in platforms:
condition = games[games.Platform == p]
platform_count.append(condition["Platform"].count())
plt.pie(platform_count, labels=platforms,
shadow=True, startangle=600)
#plt.legend(platforms, loc=2)
#autopct='%1.1f%%',
plt.show()
print(platforms)
print(platform_count)
games.loc[:, ["Rank", "Name"]]
games.boxplot()
plt.show()
million = pow(10,6)
sales = games.loc[:, ["NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"]]*million
sales.boxplot()
plt.show()
globall = games.loc[:,["Global_Sales"]]*million
globall.boxplot()
plt.show()
all_sales = games.loc[:, ["NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"]]
sns.heatmap(all_sales.corr(), annot=True)
plt.show()
data = games.drop(["Rank"], axis=1)
data
games[games.JP_Sales == games["JP_Sales"].max()]
Pokémon Red & Blue (Türkçe: Pokémon Kırmızı ve Mavi), ilk olarak 1996 yılının ilk çeyreğinde Japonya'da Pocket Monsters: Red & Green sürümleriyle piyasaya sürülmüştür. Aynı yılın son çeyreğinde Pocket Monsters: Blue versiyonunu piyasaya sürdükten sonra Dünya'ya açılmaya karar veren Nintendo, oyunu Kırmızı ve Mavi sürümleri üzerinden diğer ülkelerde yer edinmeye karar vermiştir. İlk önce 1998 yılının üçüncü çeyreğinde Amerika'da, ardından aynı yılın dördüncü çeyreğinde Avustralya'da yerini alan oyunlar, 1999 yılının son çeyreğinde Avrupa'da yaygınlaşmaya başlamıştır. Oyunların Nintendo 3DS ve 2DS konsollarıyla uyumlu sanal sürümleri ise 2016 yılında yayınlanmıştır.
Geliştirici: Game Freak (Japon merkezli bir oyun şirketi) Yayımcı: Nintendo (Japon merkezli bir oyun konsolu) Yapımcı: Shigeru Miyamoto (Japon)
#not: en alttaki deÄŸer max
max_jp = games.sort_values("JP_Sales")
max_jp.tail(10)
max_eu = games.sort_values("EU_Sales")
max_eu.tail(10)
max_na = games.sort_values("NA_Sales")
max_na.tail(10)
max_other = games.sort_values("Other_Sales")
max_other.tail(10)
max_global = games.sort_values("Global_Sales")
max_global.tail(10)
games[games.Year == games["Year"].max()]
#NaN satırları siler
games = games.dropna()
sort_year = games.sort_values("Year")
sort_year.tail()
games[games.Year == games["Year"].min()]
games[games.Year == 1980].shape
games[games.Year == 1981].shape
games[games.Year == 1982].shape
games[games.Year == 1983].shape
games[games.Year == 1984].shape
games[games.Year == 1985].shape
games[games.Year == 1986].shape
games.Genre.value_counts()
games.Year.value_counts()
games.Publisher.value_counts().head(20)
games[games.Publisher == "Electronic Arts"].head(10)
games.Publisher.value_counts(normalize=True)
games[['Publisher','Year']].dtypes
games.Year = games.Year.astype('int32')
games.Year.dtypes
games.isna().any()
# Muhtemelen tipi string olan kategorileri çekiyor
categorical_df = games.select_dtypes("O")
categorical_df.head()
numerical_df =games.select_dtypes("int", "float")
numerical_df.head()
from plotly import graph_objects as go
from plotly import express as px
#I just used this to learn in the plotly library. I will not use this part in the main project
top_10_publisher = games.Publisher.value_counts().head(10)
px.bar(top_10_publisher, title= "Top 10 Video Game Publishers",
labels={
"value" : "Number of Games Publishing",
"index" : "Name of the Publisher"
})
#I just used this to learn in the plotly library. I will not use this part in the main project
top_10_genres = games.Genre.value_counts()
fig = px.bar(top_10_genres, title="Top 10 Video Game Genres",
labels={
"value" : "Number of Games Genres",
"index" : "Name of the Genre"
})
fig.show()
fig = px.scatter(top_10_genres, title = "Top Genres Games",
labels={
"value" : "Numbers",
"index" : "Genre"
})
fig.show()
#I just used this to learn in the plotly library. I will not use this part in the main project
top_10_platform = games.Platform.value_counts().sort_values()
fig = px.line(top_10_platform)
fig.show()
#SATIS TOPLAMLARI
#I just used this to learn in the plotly library. I will not use this part in the main project
from plotly.offline import init_notebook_mode, iplot
year_wise_sales = games.loc[:,["Name", "Year", "NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"]].groupby(by="Year").sum()
fig1 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["NA_Sales"], name="North America's Sales", line_shape="vh")
fig2 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["EU_Sales"], name="Europe's Sales", line_shape="vh")
fig3 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["JP_Sales"], name="Japan's Sales", line_shape="vh")
fig4 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["Other_Sales"], name="Other Sales", line_shape="vh")
figs = [fig1, fig2, fig3, fig4]
layout = dict(title="Year Wise Totan Game Sales of North America , Europe, Japan and Other Country",
xaxis = dict(title = "Year"), yaxis=dict(title = "Total Sales In Millions"))
figure=dict(data=figs, layout=layout)
iplot(figure)
#SATIS ORTALAMASI
#I just used this to learn in the plotly library. I will not use this part in the main project
from plotly.offline import init_notebook_mode, iplot
year_wise_sales = games.loc[:,["Name", "Year", "NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"]].groupby(by="Year").mean()
fig1 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["NA_Sales"], name="North America's Sales", line_shape="vh")
fig2 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["EU_Sales"], name="Europe's Sales", line_shape="vh")
fig3 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["JP_Sales"], name="Japan's Sales", line_shape="vh")
fig4 = go.Scatter(x = year_wise_sales.index, y=year_wise_sales["Other_Sales"], name="Other Sales", line_shape="vh")
figs = [fig1, fig2, fig3, fig4]
layout = dict(title="Year Wise Totan Game Sales of North America , Europe, Japan and Other Country",
xaxis = dict(title = "Year"), yaxis=dict(title = "Total Sales In Millions"))
figure=dict(data=figs, layout=layout)
iplot(figure)
#I just used this to learn in the plotly library. I will not use this part in the main project
fig = px.scatter(games, x="Year", y="Global_Sales", color="Genre", size="Global_Sales",
hover_data=["Name"], title="Year Wise Global Video Game Sales by Genre",
labels={"x": "Years", "y": "Global Sales In Millions"})
fig.show()
#I just used this to learn in the plotly library. I will not use this part in the main project
top_sales = games.sort_values(by=["NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"], ascending=False).head(10)
top_sales
#I just used this to learn in the plotly library. I will not use this part in the main project
dicts_name = {
"NA_Sales" : "North America Sales (In Millions)",
"EU_Sales" : "Europe Sales (In Millions)",
"JP_Sales" : "Japan_Sales (In Millions)",
"Other_Sales" : "Other Sales (In Millions)"
}
for(key, title) in dicts_name.items():
fig = px.sunburst(top_sales, path=["Genre", "Publisher", "Platform"], values=key, title="Top Selling by " + title)
fig.update_layout(
grid=dict(columns=2, rows=2),
margin=dict(t=40, l=2, r=2, b=5))
fig.show()
games.Genre.value_counts()
games[games.Name == "Dark Souls"]
games[games.Name == "Resident Evil"]
games[games.Name == "Silent Hill"]
games[games.Name == "The Elder Scrolls V: Skyrim"]
games[games.Name == "Silent Hill"]
# games[games.Name == "Red Dead Redemption"]